package com.cf.r1045;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class c {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        int T = Integer.parseInt(br.readLine());
        while (T-- > 0) {
            solve();
        }
        out.flush();
        out.close();
        br.close();
    }

    static void solve() throws IOException {
        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        in = br.readLine().split(" ");
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = Long.parseLong(in[i]);
        }
        long ans = 0;
        for (int i = 1; i < n; i += 2) {
            long left = a[i - 1];
            long right = (i + 1 < n) ? a[i + 1] : 0;
            long x = left + right - a[i];
            if (x <= 0) continue;
            if (right > x) {
                a[i + 1] -= x;
                ans += x;
            } else {
                if (i + 1 < n) {
                    a[i + 1] -= right;
                    a[i - 1] -= (x - right);
                } else {
                    a[i - 1] -= x;
                }
                ans += x;
            }
        }
        out.println(ans);

    }
}
